﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="favicon.ico">
    <link href="~/hplus/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="~/hplus/css/animate.min.css" rel="stylesheet">
    <link href="~/hplus/css/style.min.css?v=4.0.0" rel="stylesheet">
    <link href="~/Xadmin/lib/layui/css/layui.css" rel="stylesheet" />
    <script src="~/Xadmin/lib/layui/layui.js"></script>
    <script src="~/Scripts/jquery-3.4.1.min.js"></script>
    <script src="~/Xadmin/js/xadmin.js"></script>
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content">
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body ">
                            <div class="layui-inline layui-show-xs-block">
                                <input class="layui-input" name="searContent" id="crReload" placeholder="请输入商品名" autocomplete="off">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input class="layui-input" name="sertype" id="sertype" placeholder="请输入类型" autocomplete="off">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <button class="layui-btn" id="btncrReload" onclick="SelectName()" data-type="reload">搜索</button>
                            </div>
                        </div>
                        <div class="layui-card-body layui-table-body layui-table-main">
                            <table class="layui-hide" id="supplierTable" lay-filter="supplierTable"></table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script type="text/html" id="barContract">
            <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">入库</a>
            <a class="layui-btn layui-btn-xs" lay-event="edit">出库</a>
        </script>
        <script>
            //根据名字搜索
            function SelectName() {
                layui.table.reload('supplierTable', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: {
                        name: $("#crReload").val(),
                        sertype: $("#sertype").val()
                    }
                });
            }
            layui.use('table', function () {
                var table = layui.table;
                table.render({
                    elem: '#supplierTable'
                    , url: '/api/GoodHouse/get'
                    , limit: 15
                    , limits: [15, 25, 35]
                    , title: '用户数据表'
                    , cols: [[
                        { field: 'Name', title: '商品名', fixed: 'left', unresize: true }
                        , { field: 'Num', title: '数量', sort: true }
                        , { field: 'Unit', title: '单位', sort: true }
                        , { field: 'TypeName', title: '种类', sort: true }
                        , { fixed: 'right', title: '操作', width: 180, toolbar: '#barContract' }
                    ]]
                    , page: true
                });
                //监听行工具事件
                table.on('tool(supplierTable)', function (obj) {
                    var data = obj.data;
                    if (obj.event === 'detail') {
                        layer.open({
                            type: 2,
                            title: '入库',
                            fixed: false, //不固定
                            maxmin: true,
                            content: '/Warehouse/WareAdd',
                            area: [470 + 'px', 300 + 'px'],
                            success: function (layero, index) {
                                var iframe = window['layui-layer-iframe' + index];
                                //调用子页面的全局函数
                                iframe.child(data.goodid,data.Name,'GoodHouse');
                            }
                        });
                        //xadmin.open('查看', `/Sale/SaleRecordDetail/${data.id}`, 800, 700);
                    }
                    else if (obj.event === 'edit') {
                        layer.open({
                            type: 2,
                            title: '出库',
                            fixed: false, //不固定
                            maxmin: true,
                            content: '/Warehouse/WareLess',
                            area: [470 + 'px', 300 + 'px'],
                            success: function (layero, index) {
                                var iframe = window['layui-layer-iframe' + index];
                                //调用子页面的全局函数
                                iframe.child(data.goodid, data.Name, 'GoodHouse', data.Num);
                            }
                        });
                    } 
                });
            });
        </script>
    </div>
</body>
</html>
